from HTMLTestRunner import HTMLTestRunner
import unittest
import ddt
import requests
from common.excel_read import ExcelUtil

excel = ExcelUtil(r'..\excel_data\login.xls', 'Sheet1')


@ddt.ddt
class DataTest1(unittest.TestCase):
    # @classmethod
    # def setUpClass(cls):
    #     cls.sess = requests.session()
    #     cls.sess.post(url=data['URL'], params=eval(data['parameter']))
    #
    # @classmethod
    # def tearDownClass(cls):
    #     cls.sess.close()

    @ddt.data(*excel.next())
    def testLogin(self, data):
        result = requests.post(url=data['URL'], params=eval(data['parameter']))
        print(data['URL'])
        print(result.text)
        assert data['result'] in result.text

